<?php
// +----------------------------------------------------------------------
// | 用户签到
// +----------------------------------------------------------------------
namespace app\common\model;
use think\Model;
use think\Validate;

class UserHfLog extends Model
{
	
	// ----------------
	// ---模型事件---
	//----------------
	protected static function init()
	{
    	//插入前验证
    	self::event('before_insert', function ($param) {
	    	$validate = new Validate;
			$validate->rule([
				'uid|用户id'=>'require|integer',
				'shop_id|店铺id'=>'require|integer',
				'proj_id|项目id'=>'require|integer',
				'type|类型'=>'require',
				'content|内容'=>'require',
				'hf_id|回访人id'=>'require',
				'hf_name|回访人名称'=>'require',
			]);
	        if(!$validate->check($param)){
	        	throw new \think\Exception($validate->getError());
	        }
        });
    }
	
	//项目，一对一关联
	public function project(){
        return $this->hasOne('goods','id','proj_id')->bind([
        	'proj_name'=>'name'
        ]);
    }	
}
